package com.xq.action;

import com.xq.factory.BeanFactory;
import com.xq.pojo.User;
import com.xq.service.UserService;
import com.xq.service.impl.UserServiceImpl;

/**
 * @author xq
 * @version 1.0
 * @date 2021/4/5 15:16
 * @description 用户控制层
 */
public class UserAction {
    private UserService userService = new UserServiceImpl();

    /**
     * 使用工厂模式创建对象
     */
    private UserService userService2 = BeanFactory.getUserService();

    /**
     * 通过类全名反射创建对象
     */
    private UserService userService3 = BeanFactory.getBean("com.xq.service.impl.UserServiceImpl");

    /**
     * 通过类名反射创建对象
     */
    private UserService userService4 = BeanFactory.getBeanProp("userService");

    public void getUserById(){
        Integer id = 1;
        User u = userService4.getUserById(id);
        System.out.println(u);
    }
}
